This is the “Hello World” of Hyperledger Composer samples, which demonstrates the core functionality of Hyperledger Composer by changing the value of an asset.
// Add the asset, then get the asset. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.add(asset3); });
}) .should.be.rejectedWith(/does not have .* access to resource/);
// Add the asset, then get the asset. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.add(asset4); });
}) .should.be.rejectedWith(/does not have .* access to resource/);
// Update the asset, then get the asset. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.update(asset2); });
}) .should.be.rejectedWith(/does not have .* access to resource/);
// Update the asset, then get the asset. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.update(asset1); });
}) .should.be.rejectedWith(/does not have .* access to resource/);
});
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
it('Alice can remove her assets', () => {
// Use the identity for Alice. return useIdentity(aliceCardName) .then(() => {
// Remove the asset, then test the asset exists. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.remove('1') .then(() => { return assetRegistry.exists('1'); }); });
}) .should.eventually.be.false;
});
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
it('Alice cannot remove Bob\'s assets', () => {
// Use the identity for Alice. return useIdentity(aliceCardName) .then(() => {
// Remove the asset, then test the asset exists. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.remove('2'); });
}) .should.be.rejectedWith(/does not have .* access to resource/);
});
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
it('Bob can remove his assets', () => {
// Use the identity for Bob. return useIdentity(bobCardName) .then(() => {
// Remove the asset, then test the asset exists. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.remove('2') .then(() => { return assetRegistry.exists('2'); }); });
}) .should.eventually.be.false;
});
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
it('Bob cannot remove Alice\'s assets', () => {
// Use the identity for Bob. return useIdentity(bobCardName) .then(() => {
// Remove the asset, then test the asset exists. return businessNetworkConnection.getAssetRegistry('org.acme.sample.SampleAsset') .then((assetRegistry) => { return assetRegistry.remove('1'); });
}) .should.be.rejectedWith(/does not have .* access to resource/);